<template>
    <div class="blank"></div>
    <Form v-if="pForm" :instance="pForm">
        <template #top>
            <div style="text-align: right;"><a class="textbutton" href="https://lbs.amap.com/tools/picker"
                    target="_blank">坐标拾取</a>
            </div>
        </template>
        <div class="apppadding">
            <Button @click="add" size="large" type="primary">完成</Button>
        </div>
    </Form>
    <bCropper v-model:img="tempImg"></bCropper>
</template>

<script lang="ts" setup>
import Form from "@m/components/public/b_form.vue";
import { useRouter } from "vue-router";
import { Button } from "vant";
import { UserForm } from "@b/index/user";
import bCropper from "@m/components/public/b_cropper.vue";
import { ref, watch } from "vue";
const router = useRouter()
const pForm = new UserForm()
const tempImg = ref('');

pForm.init()
pForm.showCroppe = (url: string) => {
    tempImg.value = url
}
watch(tempImg, (url) => {
    pForm.data.headImg = url
})
const add = async () => {
    const res = await pForm.updateData()
    if (res) {
        router.back()
    }
}
</script>